package com.logistics.modules.transportationManagement.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.logistics.modules.transportationManagement.entity.CargotypeEntity;
import com.logistics.modules.transportationManagement.service.CargotypeService;
import com.logistics.common.utils.PageUtils;
import com.logistics.common.utils.R;



/**
 * 
 *
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-06 18:12:10
 */
@RestController
@RequestMapping("/transportationManagement/cargotype")
public class CargotypeController {
    @Autowired
    private CargotypeService cargotypeService;


    /**
     * 列表
     *
     * @param params 参数个数
     * @return {@link R}
     */
    @GetMapping("/list")
    @RequiresPermissions("transportationManagement:cargotype:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = cargotypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("transportationManagement:cargotype:info")
    public R info(@PathVariable("id") Integer id){

		CargotypeEntity cargotype = cargotypeService.getById(id);

        return R.ok().put("cargotype", cargotype);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("transportationManagement:cargotype:save")
    public R save(@RequestBody CargotypeEntity cargotype){

		cargotypeService.save(cargotype);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("transportationManagement:cargotype:update")
    public R update(@RequestBody CargotypeEntity cargotype){

		cargotypeService.updateById(cargotype);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("transportationManagement:cargotype:delete")
    public R delete(@RequestBody Integer[] ids){

		cargotypeService.deleteByIds(Arrays.asList(ids));

        return R.ok();
    }

}
